#ifndef _GlsxCommon_GsLog_H_
#define _GlsxCommon_GsLog_H_

#include "GlsxCommon.h"

#include <sstream>
#include <string>

BEGIN_GLSX_NAMESPACE


enum TLogLevel { logINFO, logWARNING, logERROR, logMax};

// Use example:
// DGsLog(logERROR) << "abc" << 10 << "abc" << std::endl;


class GlsxCommon_API GsLog
{
public:
	GsLog();

	virtual ~GsLog();
	std::ostringstream& Get(TLogLevel level, int line_no, const char* filename);
public:
	TLogLevel& ReportingLevel();

protected:
	std::string Level2String(TLogLevel level);
protected:
	std::ostringstream os;
private:
	GsLog(const GsLog&);
	GsLog& operator =(const GsLog&);
private:
	static TLogLevel eMessageLevel;
};

#define DGsLog(level)		\
	if (level > logMax) {}	\
	else GsLog().Get(level, __LINE__, __FILE__)


GlsxCommon_API int FlushLogFile();


END_GLSX_NAMESPACE

#endif